package com.aizuda.boot.modules.business.filling.controller;

import com.aizuda.boot.modules.business.contract.dto.SingleResponse;
import com.aizuda.boot.modules.business.filling.domain.request.PageQuery;
import com.aizuda.boot.modules.business.filling.domain.request.SaveFilingDTO;
import com.aizuda.boot.modules.business.filling.domain.request.UpdateFilingDTO;
import com.aizuda.boot.modules.business.filling.domain.response.FilingShowDTO;
import com.aizuda.boot.modules.business.filling.domain.response.FilingShowListDTO;
import com.aizuda.boot.modules.business.filling.service.ContractFilingService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * @Author sangyirong
 * @ClassName FilingController
 * @Version 1.0
 * @Date 2025/6/4 15:39
 */
@Slf4j
@RestController
@Tag(name = "归档管理接口", description = "归档管理相关接口")
@RequestMapping("/filing")
public class FilingController {

    @Resource
    private ContractFilingService contractFilingService;


    @Operation(summary = "创建归档", description = "创建新的归档记录")
    @PostMapping
    public SingleResponse<Void> createFiling(@RequestBody SaveFilingDTO dto) {
        return contractFilingService.createFiling(dto);
    }

    @Operation(summary = "获取归档", description = "根据ID获取归档详情")
    @GetMapping("/{id}")
    public SingleResponse<FilingShowDTO> getFiling(@Parameter(description = "归档ID") @PathVariable Integer id) {
        return contractFilingService.getFiling(id);
    }

    @Operation(summary = "更新归档", description = "更新归档信息")
    @PutMapping
    public SingleResponse<Void> updateFiling(@RequestBody UpdateFilingDTO dto) {
        return contractFilingService.updateFiling(dto);
    }

    @Operation(summary = "删除归档", description = "根据ID删除归档")
    @DeleteMapping("/{id}")
    public SingleResponse<Void> deleteFiling(@Parameter(description = "归档ID") @PathVariable Integer id) {
        return contractFilingService.deleteFiling(id);
    }

    @Operation(summary = "获取归档列表", description = "分页获取归档列表")
    @PostMapping("/list")
    public SingleResponse<IPage<FilingShowListDTO>> getFilingList(@RequestBody PageQuery pageQuery) {
        return contractFilingService.getFilingList(pageQuery);
    }
}
